package com.songlanyun.modules.celebrity.controller.api;

import com.songlanyun.common.annotation.RepeatSubmit;
import com.songlanyun.common.annotation.SysLog;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;
import com.songlanyun.modules.account.controller.common.AbstractApiController;
import com.songlanyun.modules.celebrity.entity.UserApplyNetRed;
import com.songlanyun.modules.celebrity.model.UserApplyNetRedDTO;
import com.songlanyun.modules.celebrity.service.UserApplyNetRedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * 网红申请 API
 *
 * @author zx
 * @date 2021年3月2日 15:44:33
 */
@RestController
@RequestMapping("api/celebrity")
public class UserApplyNetRedApiController extends AbstractApiController {
    @Autowired
    private UserApplyNetRedService userApplyNetRedService;


    /**
     * 信息
     */
    @RequestMapping("/info")
    public R info() {
        return R.ok().put("data", userApplyNetRedService.queryOneByUserId(getUserId(true)));
    }


    /**
     * 保存
     */
    @RepeatSubmit(value = "3")
    @PutMapping("/save")
    public R save(@RequestBody UserApplyNetRedDTO dto) {
        UserApplyNetRed userApplyNetRed = userApplyNetRedService.addEntity(getUserId(true), dto);

        return R.ok().put("data", userApplyNetRed);
    }

    /**
     * 网红申请列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        params.put("userId", getUserId(true));
        PageUtils page = userApplyNetRedService.queryPage(params);
        return R.ok().put("page", page);
    }

}
